import * as OpenCC from 'opencc-js';


// const converter = OpenCC.ConverterFactory(
//   OpenCC.Locale.from.cn,                   // Simplified Chinese (Mainland China) => OpenCC standard
//   OpenCC.Locale.to.tw // OpenCC standard => Traditional Chinese (Taiwan) with custom words
// );
// console.log(converter('悟空道：“师父又来了。怎么叫做‘水中捞月’？”'));
// // output: 悟空道：「師父又來了。怎麼叫做『水中撈月』？」
export default {
	namespaced: true,
	state: {
		lang: '',
		converter: null
	},
	mutations: {
		switchLang(state, data) {
			console.log('设置语言包为' + data);
			state.lang = data
			if (state.lang == 'cn') {
				state.converter = OpenCC.ConverterFactory(OpenCC.Locale.from.hk, OpenCC.Locale.to.cn)
			} else {
				state.converter = OpenCC.ConverterFactory(OpenCC.Locale.from.cn, OpenCC.Locale.to.hk)
			}
		}
	}
}